﻿package frEngine.shader.filters.fragmentFilters
{
    import __AS3__.vec.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;

    public class RimLightFilter extends FilterBase
    {
        private var _strengthValue:Vector.<Number>;
        public var rimColor:Vector.<Number>;

        public function RimLightFilter()
        {
            this._strengthValue = this.Vector.<Number>([1.6, 1, 1.3, -1]);
            this.rimColor = this.Vector.<Number>([0, 0, 0, 1]);
            super(FilterType.RimLightFilter, FilterPriority.RimLightFilter);
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            param1.getParamByName("{RimColor}", false).value = this.rimColor;
            param1.getParamByName("{RimParams}", false).value = this._strengthValue;
            return;
        }// end function

        override public function get programeId() : String
        {
            return "RimLight0";
        }// end function

        override public function clone() : FilterBase
        {
            return this;
        }// end function

        public function set StrengthValue(param1:Number) : void
        {
            this._strengthValue[1] = param1;
            return;
        }// end function

        override public function createVertexCode(param1:Program3dRegisterInstance, param2:int) : String
        {
            var _loc_3:Array = [new ToBuilderInfo("vf1", "{V_GloblePos}", false, 1)];
            param1.toBuild("", _loc_3);
            return "";
        }// end function

        override public function createFragmentColor(param1:Program3dRegisterInstance, param2:Boolean) : String
        {
            var _loc_3:Array = [new ToBuilderInfo("fc2", "{RimColor}", false, 1, this.rimColor), new ToBuilderInfo("fm0", FilterName.worldView, true, 4), new ToBuilderInfo("fc3", "{RimParams}", false, 1, this._strengthValue)];
            var _loc_4:* = "" + "m33 ft2.xyz,{vnormal},fm0 \n" + "nrm ft2.xyz,ft2.xyz\t\n" + "abs ft3.x, ft2.z\t\n" + "div ft3.x, ft3.x, {RimParams}.z \n" + "sat ft3.x,ft3.x\t\n" + "pow ft3.x, ft3.x, {RimParams}.y \n" + "mul ft3.x, ft3.x, {RimParams}.x \n" + "sat ft3.x,ft3.x\t\n" + "sub ft3.w,{fcConst1}.z,ft3.x \n" + "mul ft3.xyz,{RimColor}.xyz,ft3.w \n" + "mul ft3.xyz,ft3.xyz,{output}.w \n" + "add {output}.xyz,{output}.xyz,ft3.xyz \n" + "min {output}.xyz,{output}.xyz,{fcConst1}.z \n";
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            return _loc_4;
        }// end function

    }
}
